package 南通大学;

import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import 湖北工业大学.HbGuBean;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class NTu {
    //南通大学
    public static void main(String[] args) throws IOException {
        NTuBean nTuBean = null;
        List<NTuBean> nTuBeans = new ArrayList<>();
        Connection connect = Jsoup.connect("https://dqxy.ntu.edu.cn/bsds/list.htm");
        Document post1 = connect.post();
        for (Element elementsByClass : post1.getElementsByClass("Article_Title")) {
            for (Element element : elementsByClass.getElementsByTag("a")) {
                nTuBean = new NTuBean();
                nTuBean.setT_name(element.text());
                System.out.println(element.attr("href"));
                Connection connect1 = Jsoup.connect("https://dqxy.ntu.edu.cn" + element.attr("href"));
                Document post11 = connect1.post();
                String text = post11.getElementsByClass("wzcon cleafix").text();
                nTuBean.setInfo(text);
                nTuBeans.add(nTuBean);
            }

        }
        EasyExcel.write("src/NTu.xlsx", NTuBean.class).sheet("user").doWrite(nTuBeans);

    }

}
